如何透過 Vagrant,快速建立Jenkins 發表於 2016-01-14 | 分類於 Programmer , Vagrant 安裝步驟12345678910111213141516171819202122232425262728# 透過Vagrant建立CentOS# 先下載Vagrant box ## 檔案會下載至 ~/.vagrant.d/boxes## centos64 是為了這個box取的名稱vagrant box add centos64 https://github.com/2creatives/vagrant-centos/releases/download/v6.4.2/centos64-x86_64-20140116.box#建立Vagrant的資料夾mkdir your_path/jenkins_vm_projectcd your_path/jenkins_vm_project#透過剛剛下載的 centos64.box 來建立vagrant vm#會產生Vagrant filevagrant init centos64 #修改產生出的Vagrant file, 修改後存檔#vagrant 啟動時加入bootstrap.shconfig.vm.provision :shell, path: "bootstrap.sh" #將 host 的 8080 port 轉向VM的 8080 portconfig.vm.network "forwarded_port", guest: 8080, host: 8080#在your_path/jenkins_vm_project 目錄下建立bootstrap.sh,並寫上Jenkins的安裝步驟, 內容於下方block。vim bootstrap.sh #啟動Vagrant vagrant up#p.s. Jenkins 需要 java1.7版本以上。 12345678910#!/usr/bin/env bashyum -y install wgetyum -y install vimyum -y install java-1.7.0-openjdkyum updatewget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.reporpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.keyyum -y install jenkins